package SanZiQi;

import java.util.Scanner;

import static SanZiQi.game.*;


public class SanZiQi {
//三子棋
  public static void game() {
      System.out.println("*************************");
      System.out.println("******* 1. 三子棋  *******");
      System.out.println("******* 2. 五子棋  *******");
      System.out.println("******* 0. 退出游戏 *******");
      System.out.println("*************************");
  }
    public static void play(int x,int y) {
      //初始化棋盘
        char[][]array=new char[x][y];

        initialize(array,x,y);
        print(array,x,y);
       int p=0;
        while (true) {
      //玩家下棋
      game_Player(array, x, y);
      //打印棋盘
      print(array, x, y);
      //判断
            if(panDan(array,x,y)!=-1) {//判断
                break;
            }
      //电脑下棋
      game_Ai(array, x, y);
            //打印棋盘
      print(array, x, y);
            //判断
      if(panDan(array,x,y)!=-1) {//判断
               break;
            }
        }
  }
  public static void main(String[] args) {
  //实现菜单
      int p=0;
    Scanner n=new Scanner(System.in);
    do {
        game();
        p=n.nextInt();
        switch (p){
            case 1 :
                //进入游戏
                play(3,3);
                break;
            case 2:
                play(10,10);
            case 0 :
                //退出游戏
                System.out.println("退出成功");
                break;
            default:
                System.out.println("输入错误请重新输入");
        }
    }while(p!=0);

    }
}
